<?php
session_start();

$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="smartinterview"; // Database name
$tbl_name="logintime_details"; // Table name
$name = $_SESSION['username'];
 
$ipaddress = $_SERVER['REMOTE_ADDR'];



mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql="INSERT INTO `$tbl_name` (userID,login_time,logout_time,IPaddress,Status)
         VALUES('$name',now(),'','$ipaddress','active')";
		 $result=mysql_query($sql);
		 $status= "active";
$sql1="UPDATE login_details SET Status='$status' WHERE UserName='$name'";
$result1=mysql_query($sql1);

         // Check connection
           // if (mysqli_connect_errno())
            // {
           //echo "Failed to connect to MySQL: " . mysqli_connect_error();
            // }
			//$sql="INSERT INTO 'logintime_details' (UserID,login_time,logout_time,IPaddress,Status)
         //VALUES('$_SESSION['$username']','$_SERVER['REQUEST_TIME']','','$_SERVER['REMOTE_ADDR']','')";
		 // if (!mysqli_query($con,$sql))
          //{
          //die('Error: ' . mysqli_error($con));
          // }
		   
		   
?>

<html>
<body>
Login Successful
<a href="logout.php">Log out</a>
</body>
</html>